package com.jxs.android.weixi;

import android.view.LayoutInflater;
import android.view.View;

import com.jxs.android.weiget.FilterViewContent_Common;
import com.jxs.android.weiget.FilterViewCreatedListener;
import com.jxs.android.weiget.LaucherTopBar;
import com.jxs.android.weixi.data.Filter_Data_Common;
import com.telecom.weixi.R;
import com.telecom.weixi.R.array;

public class MyCustomer_User_Laucher extends MyLaucher {

	private FilterViewContent_Common contentView;

	private LaucherTopBar topBar;

	@Override
	public void onClick(View v) {
		super.onClick(v);
		if (v.getId() == option_1_ll.getId()) {
			show(direction, MyCustomer_User_Laucher_User.class, array.my_customer_user_sort);
		} else if (v.getId() == option_2_ll.getId()) {
			show(direction, MyCustomer_User_Laucher_UserLosed.class, array.my_customer_loseed_user_sort);
		}
	}

	@Override
	public void show(LaucherDirection direction, Class<?> intentClass, int sortArrayid) {
		super.show(direction, intentClass, sortArrayid);
		if (direction.ordinal() == LaucherDirection.OPTION_1.ordinal()) {
			initFilterBar(R.layout.bu_my_customer_filter_user);
		} else if (direction.ordinal() == LaucherDirection.OPTION_2.ordinal()) {
			initFilterBar(R.layout.bu_my_customer_filter_user_lost);
		}
	}

	@Override
	public void topBarLogic(final LaucherTopBar topBar) {
		this.topBar = topBar;
		super.topBarLogic(topBar);
		this.topBar.setFilterBtnText(R.string.prompt_filter);
		this.topBar.hindBtn();
		this.topBar.setFilterBtnVisibility(View.VISIBLE);
		initFilterBar(R.layout.bu_my_customer_filter_user);
	}

	private void initFilterBar(int layout) {
		contentView = (FilterViewContent_Common) LayoutInflater.from(this).inflate(layout, null);
		contentView.setBtnOnClickListern(new FilterViewContent_Common.BtnOnClickListern() {
			@Override
			public void okLogic() {

				Filter_Data_Common.setConditionAccNbr(contentView.getConditionAccNbr());
				Filter_Data_Common.setConditionAddStock(contentView.getConditionAddStock());
				Filter_Data_Common.setConditionHighValue(contentView.getConditionHighValue());
				Filter_Data_Common.setConditionProduct(contentView.getConditionProduct());
				Filter_Data_Common.setConditionVipClub(contentView.getConditionVipClub());
				Filter_Data_Common.setConditionSortTag(contentView.getConditionSortTag());
				sendConditionFilterBroadCast("1");
				topBar.getFilterBtn().getPopupWindow().dismiss();
			}

			@Override
			public void cancelLogic() {
				topBar.getFilterBtn().getPopupWindow().dismiss();
			}
		});
		this.topBar.setViewAndCreatedListener(contentView, new FilterViewCreatedListener() {

			@Override
			public void onViewCreated(View v) {
			}
		});
	}

	@Override
	public int getSortArrayid() {
		return array.my_customer_user_sort;
	}

	@Override
	protected void showView(LaucherDirection direction, int sortArrayid) {

		super.showView(direction, sortArrayid);
		if (direction.ordinal() == LaucherDirection.OPTION_1.ordinal()) {
			show(direction, MyCustomer_User_Laucher_User.class, sortArrayid);
		} else if (direction.ordinal() == LaucherDirection.OPTION_2.ordinal()) {
			show(direction, MyCustomer_User_Laucher_UserLosed.class, sortArrayid);
		}
	}

	@Override
	protected void initMainView() {
		super.initMainView();

		String serv_all_num = "";
		String serv_lost_num = "";
		if (null != getIntent() && null != getIntent().getExtras()) {
			serv_all_num = getIntent().getExtras().getString("serv_all_num");
			serv_lost_num = getIntent().getExtras().getString("serv_lost_num");
		}
		option_3_ll.setVisibility(View.GONE);
		option_1_tv.setText("我的用户(" + serv_all_num + ")");
		option_2_tv.setText("离网用户(" + serv_lost_num + ")");

	}
}
